<?php

namespace Jobeet\Bundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Jobeet\Bundle\Entity\Category;

class LoadCategoryData extends AbstractFixture implements OrderedFixtureInterface
{
    public function load($manager)
    {
        $this->persistNewCategory($manager, 'Design');
        $this->persistNewCategory($manager, 'Programming');
        $this->persistNewCategory($manager, 'Manager');
        $this->persistNewCategory($manager, 'Administrator');

        $manager->flush();
    }

    private function persistNewCategory($manager, $cat_name)
    {
        $category = new Category();
        $category->setName($cat_name);
        $manager->persist($category);
        $this->addReference(strtolower($cat_name), $category);
    }

    public function getOrder()
    {
        return 1 ;
    }
}

?>